package zzx.ccf_201312;


        import java.util.ArrayList;
        import java.util.Scanner;

public class window {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, m, i, j;
        n = sc.nextInt();
        m = sc.nextInt();
        ArrayList<Rect> list = new ArrayList<>();
        for (i = 0; i < n; i++) {
            list.add(new Rect(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), i + 1));
        }
        label: // 标签，返回点击窗口的编号后，跳出嵌套，继续判断下一次点击
        for (i = 0; i < m; i++) {
            int x=sc.nextInt();
            int y=sc.nextInt();
            for (j = n-1; j >=0; j--) {
                Rect tmp = list.get(j);
                if (tmp.isClick(x, y)) {
                    System.out.println(tmp.id);
                    list.remove(j);
//					把当前变量放在首位
                    list.add(n - 1, tmp);
                    continue label;
                }
            }
            System.out.println("IGNORED");
        }
    }

    static class Rect {
         int x1;
         int x2;
         int y1;
         int y2;
        int id;

        public Rect(int x1, int y1, int x2, int y2, int id) {
            this.id = id;
            this.x1 = x1;
            this.x2 = x2;
            this.y1 = y1;
            this.y2 = y2;
        }

        public  Boolean isClick(int x, int y) {
            return (x <= x2 && x >= x1 && y <= y2 && y >= y1);
        }

    }
}
